Skip to content

feat(app): add selection-aware comments in fullscreen#58

Open
aryeko wants to merge 1 commit intoexcalidraw:mainfrom
aryeko:feat/interactive-element-selection
Open

feat(app): add selection-aware comments in fullscreen#58
aryeko wants to merge 1 commit intoexcalidraw:mainfrom
aryeko:feat/interactive-element-selection

Conversation

@aryeko
Copy link
Copy Markdown

@aryeko aryeko commented Mar 28, 2026

Summary

This PR adds selection-aware follow-up editing to the fullscreen Excalidraw widget, so users can point the model at specific diagram elements instead of only giving whole-diagram feedback.

It introduces:

  • fullscreen element selection tracking
  • a selection badge in the editor toolbar
  • anchored Comment actions for selected elements
  • structured widget context for selected elements, recent edits, and recent comments
  • tests for selection and widget-context serialization/store behavior

Problem

Today users can manually edit diagrams in fullscreen, but they cannot easily tell the model “this box” or “these two nodes” when asking for follow-up changes. That makes iterative refinement much less precise.

What Changed

Selection-aware context

  • Track selected Excalidraw elements in fullscreen
  • Exclude bound text from the visible count/context
  • Resolve labels from bound text where available
  • Send structured selection context to the model for future turns

Anchored comments

  • Show a contextual Comment affordance near the current selection
  • Let users send follow-up requests scoped to the selected element(s)
  • Only enable this when the host supports both ui/message and ui/update-model-context
  • Only persist a comment in widget context after the host accepts the message

Widget context refactor

  • Replace the old edit-context flow with a more structured widget-context controller
  • Track:
    • checkpoint id
    • current selection
    • recent edit summaries
    • recent accepted comments
    • last action metadata
  • Improve the visible text payload sent via updateModelContext

Editor/persistence cleanup

  • Split scene parsing, selection anchoring, viewport handling, and persistence into focused modules
  • Preserve checkpoint/local persistence behavior for fullscreen edits
  • Keep fullscreen editor state in sync when a new final tool result arrives

Why This Is Useful

This makes the app feel much more conversational and iterative:

  • users can select a single node and ask for a targeted change
  • the model gets structured context instead of inferring intent from a generic follow-up
  • follow-up requests are safer because failed sends no longer pollute future context

Try It

Example follow-ups once the diagram is open in fullscreen:

  • Select the Auth Service element and ask: use green
  • Select one node and ask: make this label clearer
  • Select two elements and ask: align these and add spacing

Demo

Testing

Ran:

  • npm test
  • npm run build

Added tests for:

  • selection detail/summary behavior
  • widget context store transitions
  • widget context serialization

Verified

Verified manually:

  • selecting a single element updates the badge and selection context
  • bound text is excluded from the visible count/context
  • clicking Comment opens the anchored composer near the selection
  • sending a selection-scoped request works end-to-end
  • failed sends do not appear as accepted recent comments in widget context
  • exiting fullscreen preserves user edits
  • new final tool results sync correctly into the fullscreen editor

Notes

Happy to split this if maintainers would prefer the selection badge, widget-context refactor, and anchored comments to land separately.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 28, 2026

@aryeko is attempting to deploy a commit to the Excalidraw Team on Vercel.

A member of the Team first needs to authorize it.

@aryeko aryeko force-pushed the feat/interactive-element-selection branch from f7d57f9 to 5090834 Compare March 28, 2026 07:32
@aryeko aryeko changed the title Feat/interactive element selection feat(app): add selection-aware comments in fullscreen Mar 28, 2026
@aryeko aryeko marked this pull request as ready for review March 28, 2026 08:07
@aryeko
Copy link
Copy Markdown
Author

aryeko commented Apr 2, 2026

@antonpk1 Any chance you can have a look? I think this feature will be very useful and make will make excelidraw mcp more usable and advanced than others (eg draw.io)

If the refactor is too much I can focus the pr to the functionality only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant